<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="generator" content="PHPDoctor 2RC4 (http://peej.github.com/phpdoctor/)">
<meta name="when" content="Fri, 23 Jul 2010 20:16:24 +0000">

<link rel="stylesheet" type="text/css" href="../stylesheet.css">
<link rel="start" href="../overview-summary.html">

<title>HR_transactionApi.class.php (Hosting Reborn API PHP Library)</title>

</head>
<body id="file" onload="parent.document.title=document.title;">

<div class="header">
<h1>Hosting Reborn API PHP Library</h1>
<ul>
<li><a href="../overview-summary.html">Overview</a></li>
<li>Package</li><li>Class</li><li>Tree</li><li><a href="../overview-files.html">Files</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../index-all.html">Index</a></li>
</ul>
</div>

<div class="small_links">
<a href="../index.html" target="_top">Frames</a>
<a href="../source/hr_transactionapi.class.php.html" target="_top">No frames</a>
</div>
<hr>

<h1>HR_transactionApi.class.php</h1>
<hr>

<a name="line1"></a><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<a name="line2"></a><span style="color: #009933; font-style: italic;">/** An interface to the Hosting Reborn API transaction functions
<a name="line3"></a> *
<a name="line4"></a> * @package com\hostingreborn\api
<a name="line5"></a> * @link https//api.hostingreborn.com/docs/functions/transaction/
<a name="line6"></a> *
<a name="line7"></a> * @author      Jon Cram &lt;jon@hostingreborn.com&gt;
<a name="line8"></a> * @copyright   https://api.hostingreborn.com/code/copyright/
<a name="line9"></a> * @license     https://api.hostingreborn.com/code/license/
<a name="line10"></a> * @version     1.0
<a name="line11"></a> *
<a name="line12"></a> * $Date: 2010/07/04 22:51:02 $
<a name="line13"></a> * $Revision: 2c423d307a13 $
<a name="line14"></a> *
<a name="line15"></a> * 
<a name="line16"></a> */</span>
<a name="line17"></a>&nbsp;
<a name="line18"></a><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HR_api.class.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line19"></a>&nbsp;
<a name="line20"></a><span style="color: #000000; font-weight: bold;">class</span> HR_transactionApi <span style="color: #000000; font-weight: bold;">extends</span> HR_api <span style="color: #009900;">&#123;</span>
<a name="line21"></a>&nbsp;
<a name="line22"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line23"></a>    <span style="color: #666666; font-style: italic;">/* Attributes                                                              */</span>
<a name="line24"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line25"></a>&nbsp;
<a name="line26"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line27"></a>    <span style="color: #666666; font-style: italic;">/* Constructors                                                            */</span>
<a name="line28"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line29"></a>&nbsp;
<a name="line30"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line31"></a>    <span style="color: #666666; font-style: italic;">/* Public methods                                                          */</span>
<a name="line32"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line33"></a>&nbsp;
<a name="line34"></a>&nbsp;
<a name="line35"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line36"></a>     * @link http://api.hostingreborn.com/docs/functions/transactions/get/
<a name="line37"></a>     *
<a name="line38"></a>     * @param string $key
<a name="line39"></a>     * @param string $transaction
<a name="line40"></a>     * @return stdClass
<a name="line41"></a>     */</span>
<a name="line42"></a>    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$transaction</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line43"></a>        <span style="color: #666666; font-style: italic;">/*
<a name="line44"></a>            Exceptions thrown by API:
<a name="line45"></a>                - database (handled internally by API)
<a name="line46"></a>                - system (handled internally by API)
<a name="line47"></a>        */</span>
<a name="line48"></a>&nbsp;
<a name="line49"></a>        <span style="color: #666666; font-style: italic;">// Prepare request variables</span>
<a name="line50"></a>        <span style="color: #000088;">$queryString</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/http_build_query"><span style="color: #990000;">http_build_query</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
<a name="line51"></a>                <span style="color: #0000ff;">'key'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span>
<a name="line52"></a>                <span style="color: #0000ff;">'transaction'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$transaction</span>
<a name="line53"></a>        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line54"></a>&nbsp;
<a name="line55"></a>        <span style="color: #666666; font-style: italic;">// Send request</span>
<a name="line56"></a>        <span style="color: #000088;">$transactionXML</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'transactions/get/?'</span><span style="color: #339933;">.</span><span style="color: #000088;">$queryString</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toXML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line57"></a>&nbsp;
<a name="line58"></a>        <span style="color: #666666; font-style: italic;">// Parse response</span>
<a name="line59"></a>        <span style="color: #000088;">$transaction</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> stdClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line60"></a>        <span style="color: #000088;">$transactionDOM</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line61"></a>        <span style="color: #000088;">$transactionDOM</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadXML</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$transactionXML</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line62"></a>&nbsp;
<a name="line63"></a>        <span style="color: #000088;">$xpath</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMXPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$transactionDOM</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line64"></a>        <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/transaction/*'</span><span style="color: #339933;">;</span>
<a name="line65"></a>&nbsp;
<a name="line66"></a>        <span style="color: #000088;">$nodes</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xpath</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line67"></a>&nbsp;
<a name="line68"></a>        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$nodes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$index</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$element</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line69"></a>            <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>
<a name="line70"></a>            <span style="color: #000088;">$expression</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/transaction/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tagName</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/text()'</span><span style="color: #339933;">;</span>
<a name="line71"></a>            <span style="color: #000088;">$xpathResult</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xpath</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">evaluate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$expression</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line72"></a>&nbsp;
<a name="line73"></a>            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$xpathResult</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">length</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line74"></a>                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$xpathResult</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> instanceof DOMText<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line75"></a>                    <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xpathResult</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">wholeText</span><span style="color: #339933;">;</span>
<a name="line76"></a>                <span style="color: #009900;">&#125;</span>
<a name="line77"></a>            <span style="color: #009900;">&#125;</span>
<a name="line78"></a>&nbsp;
<a name="line79"></a>            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line80"></a>                <span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tagName</span><span style="color: #339933;">;</span>
<a name="line81"></a>                <span style="color: #000088;">$transaction</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
<a name="line82"></a>            <span style="color: #009900;">&#125;</span>
<a name="line83"></a>        <span style="color: #009900;">&#125;</span>
<a name="line84"></a>&nbsp;
<a name="line85"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$transaction</span><span style="color: #339933;">;</span>
<a name="line86"></a>    <span style="color: #009900;">&#125;</span>
<a name="line87"></a>&nbsp;
<a name="line88"></a>&nbsp;
<a name="line89"></a>    <span style="color: #009933; font-style: italic;">/**
<a name="line90"></a>     * @link http://api.hostingreborn.com/docs/functions/transactions/list/
<a name="line91"></a>     *
<a name="line92"></a>     * @param string $key
<a name="line93"></a>     * @param int $limit
<a name="line94"></a>     * @param string $from
<a name="line95"></a>     * @param string $to
<a name="line96"></a>     * @param bool $storage
<a name="line97"></a>     * @param bool $bandwidth
<a name="line98"></a>     * @param bool $buynow
<a name="line99"></a>     * @param bool $manualcredit
<a name="line100"></a>     * @param bool $subscriptionPayment
<a name="line101"></a>     * @param bool $subscriptionControl
<a name="line102"></a>     * @param string $subscriptionId
<a name="line103"></a>     * @param string $domain
<a name="line104"></a>     * @return string XML
<a name="line105"></a>     */</span>
<a name="line106"></a>    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getList<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$from</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$to</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$storage</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bandwidth</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buynow</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$manualcredit</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subscriptionPayment</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subscriptionControl</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subscriptionId</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$domain</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<a name="line107"></a>        <span style="color: #666666; font-style: italic;">/*
<a name="line108"></a>            Exceptions thrown by API:
<a name="line109"></a>                - database (handled internally by API)
<a name="line110"></a>                - system (handled internally by API)
<a name="line111"></a>        */</span>
<a name="line112"></a>&nbsp;
<a name="line113"></a>        <span style="color: #666666; font-style: italic;">// Prepare request variables</span>
<a name="line114"></a>        <span style="color: #000088;">$queryString</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/http_build_query"><span style="color: #990000;">http_build_query</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
<a name="line115"></a>                <span style="color: #0000ff;">'key'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span>
<a name="line116"></a>                <span style="color: #0000ff;">'limit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$limit</span><span style="color: #339933;">,</span>
<a name="line117"></a>                <span style="color: #0000ff;">'from'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$from</span><span style="color: #339933;">,</span>
<a name="line118"></a>                <span style="color: #0000ff;">'to'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$to</span><span style="color: #339933;">,</span>
<a name="line119"></a>                <span style="color: #0000ff;">'storage'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$storage</span><span style="color: #339933;">,</span>
<a name="line120"></a>                <span style="color: #0000ff;">'bandwidth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$bandwidth</span><span style="color: #339933;">,</span>
<a name="line121"></a>                <span style="color: #0000ff;">'instant_credit_purchase'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$buynow</span><span style="color: #339933;">,</span>
<a name="line122"></a>                <span style="color: #0000ff;">'manual_credit_addition'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$manualcredit</span><span style="color: #339933;">,</span>
<a name="line123"></a>                <span style="color: #0000ff;">'subscription_purchase'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$subscriptionPayment</span><span style="color: #339933;">,</span>
<a name="line124"></a>                <span style="color: #0000ff;">'subscription_control'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$subscriptionControl</span><span style="color: #339933;">,</span>
<a name="line125"></a>                <span style="color: #0000ff;">'subscription_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$subscriptionId</span><span style="color: #339933;">,</span>
<a name="line126"></a>                <span style="color: #0000ff;">'domain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$domain</span>
<a name="line127"></a>        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line128"></a>&nbsp;
<a name="line129"></a>        <span style="color: #666666; font-style: italic;">// Send request</span>
<a name="line130"></a>        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'transactions/list/?'</span><span style="color: #339933;">.</span><span style="color: #000088;">$queryString</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toXML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a name="line131"></a>    <span style="color: #009900;">&#125;</span>
<a name="line132"></a>&nbsp;
<a name="line133"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line134"></a>    <span style="color: #666666; font-style: italic;">/* Private methods                                                         */</span>
<a name="line135"></a>    <span style="color: #666666; font-style: italic;">/***************************************************************************/</span>
<a name="line136"></a>&nbsp;
<a name="line137"></a><span style="color: #009900;">&#125;</span>
<a name="line138"></a>&nbsp;
<a name="line139"></a><span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
<div class="header">
<h1>Hosting Reborn API PHP Library</h1>
<ul>
<li><a href="../overview-summary.html">Overview</a></li>
<li>Package</li><li>Class</li><li>Tree</li><li><a href="../overview-files.html">Files</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../index-all.html">Index</a></li>
</ul>
</div>

<div class="small_links">
<a href="../index.html" target="_top">Frames</a>
<a href="../source/hr_transactionapi.class.php.html" target="_top">No frames</a>
</div>
<hr>

<p id="footer">This document was generated by <a href="http://peej.github.com/phpdoctor/">PHPDoctor: The PHP Documentation Creator</a></p>

</body>

</html>